package com.zx.mq.hello;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 该类为消费者监听器，实际生产环境通常可以单独配置一个服务(仅添加配置文件和该监听类即可)
 */
@Component
@RabbitListener(queues = "hello")// 该注解支持方法级
public class HelloReceiver {

    // 消费者-实际中消费者可单独部署一个服务
    @RabbitHandler
    public void process(String msg) throws InterruptedException {

        System.out.println("Receiver doing...");
        Thread.sleep(1000);
        System.out.println("over: "+msg);

        // 程序结束，会自动发送ack
    }
}
